using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;

using SlimDX;
using SlimDX.Direct3D9;

using miciv;
using miciv.Rendering;
using micivCore.Components;
using miciv.Geometry;

namespace micivCore.Data
{
    public class MapTileGeometryDefinition
    {
        protected MapTileDefinition m_definition;
        public MapTileDefinition Definition
        {
            get
            {
                return this.m_definition;
            }
        }

        protected CoreContext m_coreContext;
        public CoreContext CoreContext
        {
            get
            {
                return this.Definition.CoreContext;
            }
        }

        protected string m_strID;
        public string ID
        {
            get
            {
                return this.m_strID;
            }
        }

        public IRenderer Renderer
        {
            get
            {
                return this.m_geometry.Renderer;
            }
        }

        protected Hashtable m_htblSemantics;

        public VertexDefinition VertexDefinition
        {
            get
            {
                return this.m_geometry.VertexDefinition;
            }
        }

        public List<IVertexFeeder> VertexFeeders
        {
            get
            {
                return this.m_geometry.VertexFeeders;
            }
        }

        protected IGeometry m_geometry;

        public MapTileGeometryDefinition(MapTileDefinition _definition)
        {
            this.m_definition = _definition;
            this.m_htblSemantics = new Hashtable();
        }

        public bool Initialize(XmlElement _xmlGeometry)
        {
            this.m_strID = this.CoreContext.CoreManager.GetXmlAttributeValue(_xmlGeometry, "id", "");
            this.m_geometry = new GeometryBase(this.CoreContext, _xmlGeometry, typeof(MapTileRenderable));
            return true;
        }

        public T GetSemantic<T>(string _strSemanticID)
        {
            return this.m_geometry.GetSemantic<T>(_strSemanticID);
        }

        public void Release()
        {
            this.m_geometry.Release();
        }
    }
}
